package framework.common;

import lombok.*;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "x-rpc")
public class XConfig {

    private Register register;

    private Provider provider;

    private Consumer consumer;





    @AllArgsConstructor
    @NoArgsConstructor
    @Getter
    @Setter
    @Data
    public static class Register {

        private String address;
    }

    @AllArgsConstructor
    @NoArgsConstructor
    @Getter
    @Setter
    @Data
    public static class Provider {

        private Integer port;

        public int getPort() {
            if (port == null || port == 0) {
                port = 7788;
                return port;
            }
            return port;
        }
    }

    @AllArgsConstructor
    @NoArgsConstructor
    @Getter
    @Setter
    @Data
    public static class Consumer {

        private String loadBalance;

        private String ClusterFaultTolerancePolicy;
    }


}
